package com.linkwechat.common.utils;

import com.linkwechat.common.enums.ResponseEnum;
import com.linkwechat.common.vo.CommonRsp;

/**
 * @Author 王君平
 * @Date 2024/5/27 9:09
 * @Description
 */
public class ResultUtil {
    public ResultUtil() { }

    public static <T> CommonRsp<T> success() {
        return new CommonRsp<>(ResponseEnum.SUCCESS,null);
    }

    public static <T> CommonRsp<T> success(T data) {
        return new CommonRsp<>(ResponseEnum.SUCCESS,data);
    }

    public static <T> CommonRsp<T> fail() {
        return new CommonRsp<>(ResponseEnum.FAIL,null);
    }

    public static <T> CommonRsp<T> fail(T data) {
        return new CommonRsp<>(ResponseEnum.FAIL,data);
    }

    public static <T> CommonRsp<T> fail(Integer code,String msg,T data) {
        return new CommonRsp<>(code,msg,data);
    }

    public static <T> CommonRsp<T> fail(ResponseEnum responseEnum,String msg) {
        return new CommonRsp<>(responseEnum.getCode(),msg,null);
    }

    public static <T> CommonRsp<T> fail(ResponseEnum responseEnum) {
        return new CommonRsp<>(responseEnum.getCode(),responseEnum.getMsg(),null);
    }
}
